package com.itkaien.service.impl;

import com.github.pagehelper.PageInfo;
import com.itkaien.mapper.MessageMapper;
import com.itkaien.pojo.Message;
import com.itkaien.service.MessageService;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;
    @Override
    public void saveMessage(Message message) {
        messageMapper.insert(message);
    }

    @Override
    public PageInfo<Message> selectMessage(Date beforeOutTime,Date afterOutTime , int page, int pageSize) {
        PageInfo<Message> pageInfo = new PageInfo();
        List<Message> messages = messageMapper.selectByDatepage(beforeOutTime, afterOutTime, page, pageSize);
        pageInfo.setList(messages);
        pageInfo.setPageSize(pageSize);
        pageInfo.setPages(page);
        pageInfo.setTotal(messages.size());
        return pageInfo;
    }

    @Override
    public void updateMessage(Integer[] messageid,int status) {
        messageMapper.updatebatchbymessageid(messageid,status);
    }
}
